package com.kgc.ssm.service.impl;

import com.kgc.ssm.bean.User;
import com.kgc.ssm.mapper.UserMapper;
import com.kgc.ssm.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created On : 2022/8/23 0023.
 * <p>
 * Author : shiguangchuan
 * <p>
 * Description: UserServiceImpl
 */
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public User getLoginUserInfo(String loginCode, String loginPwd) {
        return userMapper.selectUserByCodeAndPwd(loginCode,loginPwd);
    }

    @Override
    public List<User> getUserListByCondition(String queryName, Integer queryRole) {
        return userMapper.selectUserListByCondition(queryName, queryRole);
    }

    @Override
    public User getUserById(Integer userId) {
        return userMapper.selectUserById(userId);
    }

    @Override
    public void modUserInfo(User userForm) {
        userMapper.updateUserById(userForm);
    }

    @Override
    public void delUserInfo(Integer userId) {
        userMapper.deleteUserById(userId);
    }

    @Override
    public void addUserInfo(User userForm) {
        userMapper.insertUser(userForm);
    }

    @Override
    public int getUserCountByCondition(String queryName, Integer queryRole) {
        return userMapper.selectUserCount(queryName, queryRole);
    }

    @Override
    public List<User> getUserListPageByCondition(String queryName, Integer queryRole, Integer pageNo, Integer pageSize) {
        return userMapper.selectUserListPageByCondition(queryName, queryRole, pageNo, pageSize);
    }

    @Override
    public boolean modUserPwd(Integer userId, String userPwd) {
        return userMapper.updateUserPwdById(userId, userPwd) > 0;
    }
}
